package com.king.plugin.model;

import com.king.plugin.utils.StringUtil;

public class APIInfo {
    String className;
    String methodName;
    String classDesc;
    String methodDesc;
    String apiPath;
    String apiPathMd;
    String apiMethod; // 请求方式 GET POST

    public APIInfo(){}

    public APIInfo(String className, String methodName, String classDesc, String methodDesc, String apiPath) {
        this.className = className;
        this.methodName = methodName;
        this.classDesc = classDesc;
        this.methodDesc = methodDesc;
        this.apiPath = apiPath;
    }
    public APIInfo(String className, String methodName, String classDesc, String methodDesc, String apiPath, String apiMethod) {
        this.className = className;
        this.methodName = methodName;
        this.classDesc = classDesc;
        this.methodDesc = methodDesc;
        this.apiPath = apiPath;
        this.apiMethod = apiMethod;
    }

    public String getClassName() {
        return className==null?"":className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public String getMethodName() {
        return methodName==null?"":methodName;
    }

    public void setMethodName(String methodName) {
        this.methodName = methodName;
    }

    public String getClassDesc() {
        return classDesc==null?"":classDesc;
    }

    public void setClassDesc(String classDesc) {
        this.classDesc = classDesc;
    }

    public String getMethodDesc() {
        return methodDesc==null?"":methodDesc;
    }

    public void setMethodDesc(String methodDesc) {
        this.methodDesc = methodDesc;
    }

    public String getApiPath() {
        return apiPath;
    }

    public void setApiPath(String apiPath) {
        if (apiPath != null){
            apiPath = apiPath.replaceAll("\"","");
            if (!apiPath.startsWith("/")){
                apiPath = "/" + apiPath;
            }
            if (apiPath.startsWith("/")){
                apiPath = apiPath.substring(1);
            }
        }
        this.apiPath = apiPath;
    }

    public String getApiPathMd() {
        if (StringUtil.isEmpty(apiPath))
            return "./#.md";
        apiPathMd = "./API/" + apiPath.replace("/", "#") + ".md";
        return apiPathMd;
    }

    public void setApiPathMd(String apiPathMd) {
        this.apiPathMd = apiPathMd;
    }

    public String getApiMethod() {
        return apiMethod;
    }

    public void setApiMethod(String apiMethod) {
        this.apiMethod = apiMethod;
    }
}
